﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		
		teacherId = sessionAdvice.getAutherUserID();
		
		hashCode = event.getArg("Sign");
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		checked = false;
				
		try {
			
			if ( decrypt(hashCode, teacherId, "PBEWithMD5AndDES", "Hex") eq taskId ) {
				
				checked = true;
				
				targetArgs = structNew();
				structInsert(targetArgs, "TSK", taskId, true);
				structInsert(targetArgs, "TT", taskType, true);
				structInsert(targetArgs, "Sign", encrypt(taskId, teacherId, "PBEWithMD5AndDES", "Hex"), true);

				/* 载入补考教学任务 */
				sql = "SELECT 
							b.mark_mode,a.task_prog,b.course_name,
							a.cidx,b.course_code,b.course_credit,c.institute_name,
							a.mark_done,a.mark_need 
						FROM
							t_resitplan a
							INNER JOIN t_course b ON a.cid = b.cid 
							INNER JOIN t_institute c ON b.institute_id = c.institute_id 
						WHERE
							a.task_id = :taskId ";
							
				queryObj = new query( datasource=application.dnsSlave );
				
				queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
				
				rs_task = queryObj.execute( sql=sql ).getResult();
				
				markMode = rs_task.mark_mode;
				
				if ( rs_task.task_prog eq "0" or rs_task.task_prog eq "1" or rs_task.task_prog eq "2" or rs_task.task_prog eq "4" ) {
					transaction{
						
						/* 第三步 更新成绩提交数量 */
						sql = "	SELECT 
									count(tmm.scc_id) mark_need,
									SUM(
										CASE
											WHEN tmm.mark_renote = '1' and (tmm.mark_resit > 0 OR tmm.mark_resit = 0) then
										  		1
											WHEN tmm.mark_renote > '1' OR tmm.mark_renote < '1' then
												1
										 	ELSE
										  		0
									   		END
									) mark_done
							  	FROM t_temp_mark_resit tmm
								WHERE tmm.task_id = :taskId ";

						queryObj = new Query(datasource = application.dnsMaster);
						
						queryObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
						
						rs_task_mark = queryObj.execute(sql = sql).getResult();
						
						sql = "	UPDATE t_resitplan t
									SET t.mark_need = :markNeed , 
										t.mark_done = :markDone 
								WHERE t.task_id = :taskId ";
								
						updateObj = new Query(datasource = application.dnsMaster);
						
						updateObj.addParam(name="markNeed", value=rs_task_mark.mark_need, cfsqltype="cf_sql_integer");
						updateObj.addParam(name="markDone", value=rs_task_mark.mark_done, cfsqltype="cf_sql_integer");
						updateObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
						
						updateObj.execute(sql=sql);
				
					}
				}

			}
			
		}
		catch (any ecpt) {
		}
		
		/* 判断当前显示课表内容 */
		currentTab = event.getArg("TabID", "labNotice");
		
		/* 成绩提交默认为 百分制 */
		markSubmitEvent = "taskMarkResitWizardMode0";
		
		/* 设置为两级制 */
		if ( markMode eq "2" ) {
			markSubmitEvent = "taskMarkResitWizardMode2";
		}
		
		/* 设置为五级制 */
		if ( markMode eq "4" ) {
			markSubmitEvent = "taskMarkResitWizardMode4";
		}

	</cfscript>
</cfsilent>

<cfif checked >
	
	<div class="UItab">
		<div class="tabLables">
			<span <cfif currentTab eq "labNotice">class="active"</cfif> id="labNotice" tabTarget="Notice">重要事项</span>
		</div>
	</div>
	<script language="javascript" type="text/javascript">
		//<![CDATA[
		<!--
		$(document).ready(function() {
						
			/* init Tab */
			$("div.tabContent").hide();
			$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
				
			$("div.tabLables > span").click(function(){
				var $targetID = $(this).attr("tabTarget");
						
				$("div.tabLables span").removeClass("active");
				$(this).addClass("active");
							
				$("div.tabContent").not('[id="' + $targetID + '"]').hide();
				$("div.tabContent#" + $targetID).show();
			});
						
		});
		// -->
		//]]>
	</script>
	
	<div id="Notice" class="tabContent">
		
		<div class="noticeBlock">
			<div class="operation">
				<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('taskMarkResitDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载补考成绩录入名单</span></a>
			</div>
			<h3>课程补考成绩</h3>
			<p>
				<span class="img icon16x16 message"></span>
				请注意, 这里需要提交的是课程补考成绩. 请首先完成试卷批阅, 根据评分标准核定补考成绩.
			</p>
			<hr/>
		</div>
		
		<table class="UIEditable">
			<thead>
				<tr>
					<td>课程</td>
					<td width="50">课序号</td>
					<td width="90">课程号</td>
					<td width="40">学分</td>
					<td width="50">部门</td>
					<td width="60">提交进度</td>
					<td width="60">计分模式</td>
					<td width="60">状态</td>
				</tr>
			</thead>
			<tbody>
				<tr class="editRows">
					<td><cfoutput>#rs_task.course_name#</cfoutput></td>
					<td><span class="numeric"><cfoutput>#rs_task.cidx#</cfoutput></span></td>
					<td><span class="numeric"><cfoutput>#rs_task.course_code#</cfoutput></span></td>
					<td><span class="numeric"><cfoutput>#numberFormat( rs_task.course_credit, '_.__')#</cfoutput></span></td>
					<td><cfoutput>#rs_task.institute_name#</cfoutput></td>
					<td align="center"><span class="numeric"><cfoutput>#rs_task.mark_done#</cfoutput> / <cfoutput>#rs_task.mark_need#</cfoutput></span></td>
					<td><cfoutput>#dictAdvice.getMarkModeName( markMode )#</cfoutput></td>
					<td><cfoutput>#dictAdvice.getTaskMarkStat( rs_task.task_prog )#</cfoutput></td>
				</tr>
			</tbody>
		</table>

		<!--- 根据计分模式, 跳转到成绩提交页面 --->
		<div class="systemNotice">
			<h3><span class="img icon16x16 info"></span>开始录入成绩信息</h3>
			<p>注意: 您需要在学校规定的时间内完成教学任务的成绩提交. </p>
			<p>为了保证您快速, 准确的完成成绩提交工作, 请首先考虑下载成绩提交模版电子表格, 将成绩记录在电子表格以后, 再通过网络提交课程考核成绩.</p>
					
			<form id="formRemove" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL(markSubmitEvent)#</cfoutput>">
				<input type="hidden" name="TSK" value="<cfoutput>#taskId#</cfoutput>" />
				<input type="hidden" name="TT" value="<cfoutput>#taskType#</cfoutput>" />
				<input type="hidden" name="Sign" value="<cfoutput>#encrypt(taskId, teacherId, 'PBEWithMD5AndDES', 'Hex')#</cfoutput>" />
				<div class="lable"><input class="button2" type="submit" value="录入成绩" /></div>
			</form>
		</div>
		
		
	</div>
	
	
</cfif>